#!/bin/bash
wal_num=`docker exec -u postgres pg_controldata | grep checkpoint | grep WAL | awk '{print $6}'`
count=$(df -h | grep /data | awk '{print $5}' | awk -F% '{print $1}')
if [ $count -gt 80 ];then
  docker exec -u postgres - pg_archivecleanup /var/lib/postgresql/data/pg_wal $wal_num
fi